package com.aaa.exception;


import com.aaa.pojos.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result qj(Exception ec){
        log.error("报错信息"+ec);
        return Result.error("系统错误");
    }

    @ExceptionHandler
    public Result scv(DuplicateKeyException sc){
        log.error("报错信息"+sc.toString());
        return Result.error("用户名或电话号码重复");
    }
}
